# Copyright 2007, Christopher Covington <covracer@gmail.com>
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils erlay-pkg

DESCRIPTION="Yaws is a high performance HTTP 1.1 web server."
HOMEPAGE="http://yaws.hyber.org/"
SRC_URI="http://yaws.hyber.org/download/${P}.tar.gz"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~x86 ~ppc ~sparc ~amd64"
IUSE=""

DEPEND="dev-lang/erlang"

RESTRICT="primaryuri"

src_unpack() {
	unpack ${A}
	find ${S} -depth -type d -name .xvpics -exec rm -rf '{}' \;
}

src_compile() {
	econf --prefix=/usr
	emake
}

src_install() {
	make DESTDIR=${D} install || edie
	keepdir /var/log/yaws
	# We need to keep these directories so that the example yaws.conf works
	# properly
	keepdir /usr/lib/yaws/examples/ebin
	keepdir /usr/lib/yaws/examples/include
	dodoc ChangeLog LICENSE README
	insinto /etc
	newins ${FILESDIR}/yaws.conf_gentoo yaws.conf
	newinitd scripts/gentoo/init.d.yaws yaws
	newinitd scripts/gentoo/init.d.yaws yaws
}

pkg_postinst() {
	einfo "An example YAWS configuration has been setup to run on"
	einfo " 127.0.0.1:1337. Please edit /etc/yaws.conf to suit your needs."
	echo
	erlay-pkg_info
}
